package com.example.demo.controller.business;
import com.example.demo.model.ResponseMessage;
import com.example.demo.model.business.Order;
import com.example.demo.model.people.Provider;
import com.example.demo.model.warehouse.Warehouse;
import com.example.demo.service.business.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService service;

    @RequestMapping("save")
    public ResponseMessage save(Order order){
        ResponseMessage responseMessage = new ResponseMessage();
        Boolean flag = service.save(order);
        responseMessage.setFlag(flag);

        return  responseMessage;
    }

    @RequestMapping("selectAll")
    @ResponseBody
    public List<Order> selectAll(){ return service.selectAll(); }

    //    添加数据
    @RequestMapping("addOrder")
    public Integer addOrder(Order order){return service.addOrder(order);}
    //删除数据
    @RequestMapping("deleteById")
    public Boolean deleteById(Integer order_id){return service.deleteById(order_id)==1;}
    @RequestMapping("updateById")
    public Integer updateById(Order order){return service.updateById(order);}

    @RequestMapping("updateStatusById")
    public Integer updateStatusById(Integer order_id){return service.updateStatusById(order_id);}


    @RequestMapping("findOrder")
    @ResponseBody
    public List<Order> findOrder(Integer order_number,String customer_name){ return service.findOrder(order_number,customer_name);}
}
